package com.jdiv.samples.zelda.applet;

import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Dimension;
import java.net.URL;

import javax.swing.JApplet;
import javax.swing.JFrame;

import com.jdiv.JDiv;

/**
 * @author  Joyal
 */
public class Main extends JApplet{
//Global
/**
 * @uml.property  name="link"
 * @uml.associationEnd  
 */
static Link link;
static int fpg_enemigo;
static int fpg_ambiente;

//Begin
	public void init(){
	  setPreferredSize(new Dimension(320,240));
	
	  enableEvents(AWTEvent.MOUSE_EVENT_MASK);
	  enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
	  enableEvents(AWTEvent.KEY_EVENT_MASK);
	
	  setIgnoreRepaint( true ) ;
	  add( JDiv.getCanvas()) ; 
	  JDiv.appletInit(JDiv.m320x240);
	
	}
	public void start(){
		URL urlLink= getClass().getClassLoader().getResource("res/fpg/link.fpg"),
		urlEnemigo=getClass().getClassLoader().getResource("res/fpg/enemigo.fpg"),
		urlAmbiente=getClass().getClassLoader().getResource("res/fpg/ambiente.fpg");
		
		JDiv.load_fpg(urlLink);
		fpg_enemigo=JDiv.load_fpg(urlEnemigo);
		fpg_ambiente=JDiv.load_fpg(urlAmbiente);
		JDiv.put_screen(fpg_ambiente,1);
		
		link=new Link();
		new Enemigo();
	}
	
	public void stop(){
		   JDiv.close();
		}
		
	public static void main(String args[]){
	    Main applet = new Main();
	   
	    JFrame frame = new JFrame("JDiv Applet Test");
	    frame.getContentPane().add(applet);

	    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    frame.setSize(320,240);
	    frame.setVisible(true);
	    applet.init();
	    applet.start();



	}
}
